//
//  YYT_MVDescriptionTableViewCell.m
//  AudioVisualFeast
//
//  Created by 张琪 on 16/1/28.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "QL_MVDescriptionTableViewCell.h"
#import <UIImageView+WebCache.h>

@interface QL_MVDescriptionTableViewCell ()
@property (nonatomic, retain) UIImageView *imageview;
@property (nonatomic, retain) UILabel *yiren;
@property (nonatomic, retain) UILabel *name;
@property (nonatomic, retain) UILabel *relateTime;
@property (nonatomic, retain) UILabel *boTimes;
@property (nonatomic, retain) UILabel *pcTimes;
@property (nonatomic, retain) UILabel *ydTimes;
@property (nonatomic, retain) UILabel *miaoshu;
@property (nonatomic, retain) UIButton *share;

@end
@implementation QL_MVDescriptionTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.imageview = [[UIImageView alloc] initWithFrame:CGRectZero];
        [self addSubview:self.imageview];
        _imageview.contentMode = UIViewContentModeScaleAspectFill;
        self.imageview.clipsToBounds = YES;
        self.imageview.backgroundColor = [UIColor colorWithRed:30 / 255.0 green:195 / 255.0 blue:153 / 255.0 alpha:1.0];
        self.imageview.clipsToBounds = YES;
        self.imageview.layer.cornerRadius = 30;
        
        
        self.yiren = [[UILabel alloc] initWithFrame:CGRectZero];
        self.yiren.font = [UIFont systemFontOfSize:13];
        self.yiren.text = @"艺人：";
        self.yiren.textColor = [UIColor whiteColor];
        [self addSubview:self.yiren];
        
        
        self.name = [[UILabel alloc] initWithFrame:CGRectZero];
        self.name.font = [UIFont systemFontOfSize:13];
        self.name.textColor = [UIColor colorWithRed:30 / 255.0 green:195 / 255.0 blue:153 / 255.0 alpha:1.0];
        [self addSubview:self.name];
        
        
        self.relateTime = [[UILabel alloc] initWithFrame:CGRectZero];
        self.relateTime.font = [UIFont systemFontOfSize:10];
        self.relateTime.textColor = [UIColor whiteColor];
        [self addSubview:self.relateTime];
        
        
        self.boTimes = [[UILabel alloc] initWithFrame:CGRectZero];
        self.boTimes.font = [UIFont systemFontOfSize:10];
        self.boTimes.textColor = [UIColor whiteColor];
        [self addSubview:self.boTimes];
        
        
        self.pcTimes = [[UILabel alloc] initWithFrame:CGRectZero];
        self.pcTimes.font = [UIFont systemFontOfSize:10];
        self.pcTimes.textColor = [UIColor whiteColor];
        [self addSubview:self.pcTimes];
        
        
        self.ydTimes = [[UILabel alloc] initWithFrame:CGRectZero];
        self.ydTimes.font = [UIFont systemFontOfSize:10];
        self.ydTimes.textColor = [UIColor whiteColor];
        [self addSubview:self.ydTimes];
        
        
        self.miaoshu = [[UILabel alloc] initWithFrame:CGRectZero];
        self.miaoshu.font = [UIFont systemFontOfSize:12];
        self.miaoshu.numberOfLines = 0;
        
        self.miaoshu.textColor = [UIColor whiteColor];
        [self addSubview:self.miaoshu];
        
    }
    return self;
}

-(void)layoutSubviews {
    [super layoutSubviews];
    self.imageview.frame = CGRectMake(15, 15, 60, 60);
    self.yiren.frame = CGRectMake(85, 30, 50, 10);
    self.name.frame = CGRectMake(85, 50, 200, 10);
    self.relateTime.frame = CGRectMake(15, 85, 200, 10);
    self.boTimes.frame = CGRectMake(15, 105, 110, 10);
    self.pcTimes.frame = CGRectMake(135, 105, 110, 10);
    self.ydTimes.frame = CGRectMake(235, 105, 110, 10);
    self.share.frame = CGRectMake(self.bounds.size.width - 50, 30, 30, 30);
    NSDictionary *dic = @{NSFontAttributeName:[UIFont systemFontOfSize:12]};
    //    通过字典计算高度和宽度
    CGRect rect = [self.miaoshu.text boundingRectWithSize:CGSizeMake(self.bounds.size.width - 30, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    self.miaoshu.frame = CGRectMake(15, 125, self.bounds.size.width - 30, rect.size.height);
}


-(void)setArray:(NSArray *)array {
    _array = array;
    self.name.text = self.array[0];
    self.relateTime.text = [NSString stringWithFormat:@"发布时间：%@", _array[1]];
    self.boTimes.text = [NSString stringWithFormat:@"播放总次数：%@", _array[2]];
    self.pcTimes.text = [NSString stringWithFormat:@"PC端：%@", _array[3]];
    self.ydTimes.text = [NSString stringWithFormat:@"移动端：%@", _array[4]];
    
    self.miaoshu.text = _array[5];
    [self.imageview sd_setImageWithURL:[NSURL URLWithString:_array[6]]];
    
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
